var fs=require("fs");

var fsWrite=fs.createWriteStream("./4.txt");

fsWrite.write("以流的方式写入数据");

fsWrite.end();

fsWrite.on("finish",function () {
    console.log("文件写入成功");
});

fsWrite.on("error",function () {
    console.log("文件写入失败");
});